/**
 * 详情对话框
 */
var OrderInfoDlg = {
    data: {
        orderNo: "",
        playerId: "",
        totalPrice: "",
        payPrice: "",
        payBalance: "",
        orderDesc: "",
        orderStatus: "",
        produceCode: "",
        payStatus: "",
        remark: "",
        deptid: "",
        expireDate: "",
        payTime: "",
        createTime: "",
        updateTime: "",
        recordStatus: ""
    }
};

layui.use(['form', 'admin', 'ax','tableSelect','laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var laydate = layui.laydate;

    var admin = layui.admin;
    var tableSelect = layui.tableSelect;

    //让当前iframe弹层高度适应
    //admin.iframeAuto();
    laydate.render({
        elem: '#expireDate',
        min: Feng.currentDate(),
        type: 'datetime',
    });
    //表格选择
    tableSelect.render({
        elem: '#nickname',	//定义输入框input对象 必填
        checkedKey: 'id', //表格的唯一建值，非常重要，影响到选中状态 必填
        searchKey: 'phone',	//搜索输入框的name值 默认keyword-
        searchPlaceholder: '手机号码',	//搜索输入框的提示文字 默认关键词搜索
        table: {	//定义表格参数，与LAYUI的TABLE模块一致，只是无需再定义表格elem
            url:Feng.ctxPath+'/player/list',
            cols: [[
                {type: 'radio'},
                {field: 'id', hide: true, title: 'id'},
                {field: 'nickname', sort: true, align:'center',title: '用户名'},
            ]]
        },
        done: function (elem, data) {
            //选择完后的回调，包含2个返回值 elem:返回之前input对象；data:表格返回的选中的数据 []
            //拿到data[]后 就按照业务需求做想做的事情啦~比如加个隐藏域放ID...

            //alert(data[0][0].id)
            // elem.val(data.data);

            elem.parent().find("#playerId").val(data.data[0].id)
            elem.parent().find("#nickname").val(data.data[0].nickname)


        }
    })

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
/*
        if(Feng.isAfterNow($("#expireDate"))){
            Feng.info("过期时间有误");
            return false;
        }*/
        var ajax = new $ax(Feng.ctxPath + "/order/addItem", function (data) {
            Feng.success("添加成功！");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
    });
});